import java.util.ArrayList;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2022-10-10
 * Time: 9:45
 */
public class Test {
    public static String PrintMinNumber(int [] numbers) {

        if(numbers == null) return "";

        ArrayList<Integer> tmp = new ArrayList<>();
        for(int n : numbers) {
            tmp.add(n);
        }

        tmp.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer x, Integer y) {
                String s1 = x + "" + y;
                String s2 = y + "" + x;

                return s1.compareTo(s2);
            }
        });
        StringBuilder sb = new StringBuilder();
        for(int n : tmp) {
            sb.append(n);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        int[] array = {3,32,321};

        System.out.println(PrintMinNumber(array));

    }
}
